//
//  MerchantCell.m
//  FootPrint
//
//  Created by 秦 东方 on 4/12/13.
//  Copyright (c) 2013 alex tao. All rights reserved.
//

#import "MerchantCell.h"

@implementation MerchantCell

- (void)internalInit
{
    [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
    
    _realCell.frame = self.bounds;
    [self.contentView addSubview:_realCell];
    
    self.contentView.backgroundColor = [UIColor clearColor];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self internalInit];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (void) updateCell : (MerchantMessage*) message{
    
    if (!message.logo.isSys) {
        if ([[ImageManager sharedInstance] imageExistForId:message.logo.id]) {
            [_logo setLocalImageName:[[ImageManager sharedInstance] imageFileForImageId:message.logo.id]];
        } else {
            [_logo loadAsyncImage:message.logo.imageUrl];
        }
    } else {
        [_logo setSysImageWithId:message.logo.id];
    }
    if( nil != message.name){
        [_title setText:message.name];
    }
    if( nil != message.address){
        [_address setText:message.address];
    }
}


- (void)dealloc {
    [_logo release];
    [_title release];
    [_address release];
    [_realCell release];
    [_realCell release];
    [super dealloc];
}
@end
